package com.linkoog.devtools.maven.version_show.title_bar;

import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.wm.impl.FrameTitleBuilder;
import org.jetbrains.annotations.NotNull;
import org.picocontainer.MutablePicoContainer;

public class MavenVersionUpdater {

    public static final String FRAME_TITLE_BUILDER = "com.intellij.openapi.wm.impl.FrameTitleBuilder";

    public MavenVersionUpdater(){
        //TODO: fixme
        final Application application = ApplicationManager.getApplication();
        MutablePicoContainer picoContainer = application.getComponent(MutablePicoContainer.class);
        //application.getPicoContainer();
        MavenVersionFrameTitleBuilder.setDefaultBuilder((FrameTitleBuilder) picoContainer.getComponentInstance(FRAME_TITLE_BUILDER));
        picoContainer.unregisterComponent(FRAME_TITLE_BUILDER);
        picoContainer.registerComponentImplementation(FRAME_TITLE_BUILDER, MavenVersionFrameTitleBuilder.class);
    }

}
